package keter.sec.sql.base;

import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory;
import com.jfinal.plugin.activerecord.dialect.AnsiSqlDialect;
import com.jfinal.plugin.c3p0.C3p0Plugin;

public class BaseConfig {
	
	public BaseConfig(){
	
	}
	
	static{
		initDB();
	}
	
	protected static void initDB(){
		PropKit.use("database.properties");
		C3p0Plugin plugin = new C3p0Plugin(
				PropKit.get("db.url"),
				PropKit.get("db.username"),
				PropKit.get("db.password"));
//		DruidPlugin plugin = new DruidPlugin(
//				PropKit.get("db.url"),
//				PropKit.get("db.username"),
//				PropKit.get("db.password"));
//		plugin.setDriverClass("org.hsqldb.jdbcDriver");
		ActiveRecordPlugin arp = new ActiveRecordPlugin(plugin);
//		arp.setShowSql(true);
		arp.setDialect(new AnsiSqlDialect());
		arp.setContainerFactory(new CaseInsensitiveContainerFactory(true)); 
		plugin.start();
		arp.start();
	}

}